package com.ajview.admin.controller;

import com.ajview.common.core.domain.eneity.SysUser;
import com.ajview.common.utils.MessageUtils;
import com.ajview.core.config.model.SecurityModel;
import com.ajview.system.service.SysUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author ZhangJunJie
 * @Date 2022-04-26
 * <p>
 * 概要：测试控制器
 */
@RestController
public class TestController {


    @Resource
    private SysUserService sysUserServiceImpl;
    @Resource
    private SecurityModel securityModel;


    @RequestMapping("D")
    @PreAuthorize("@prs.hasPermissions('admin:test:list')")
    public String testController() {
        return "测试成功" + securityModel.isSystemUser(1L);
    }

    @RequestMapping("/sys/list")
    @PreAuthorize("@prs.hasPermissions('system:sys:list')")
    public List<SysUser> getSysUserList(HttpServletRequest request) {
        List<SysUser> list = sysUserServiceImpl.list();
//        System.out.println("查询成功");
        SysUser sysUser = new SysUser();
        sysUser.setUserId(1L);
//        sysUserServiceImpl.updateById(sysUser);

        sysUserServiceImpl.updateSysUserById(sysUser.getUserId());
        System.out.println("修改成功");

        return null;
    }

    @GetMapping("getss")
    public String getStringSS() {
        return MessageUtils.message("user.verification-code.error");
    }


}
